home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 October: Technology Seed / ADC Seed CD - October 1999.toast / FireWire / FireWire_2.1_SDK_DR3 / Source / FWIM / LynxFWIM / LynxFWIM.h < prev    next >
Encoding:
C/C++ Source or Header  |  1999-05-17  |  46.1 KB  |  1,511 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        LynxFWIM.h
  3.  
  4.     Contains:    Definitions for TI PCI-Lynx sample FWIM
  5.  
  6.     Version:    1.0
  7.  
  8.     Copyright:    © 1998 by Apple Computer, Inc., all rights reserved.
  9.  
  10.     File Ownership:
  11.  
  12.         DRI:                Eric Anderson
  13.  
  14.         Other Contact:        Clinton Bauder
  15.  
  16.         Technology:            FireWire
  17.  
  18.     Writers:
  19.  
  20.         (EA)    Eric Anderson (ewa)
  21.  
  22.     Change History (most recent first):
  23.  
  24.        <FW2>    12/21/98    EA        Checked in to main sources so we can build different.
  25.        <FW1>    12/21/98    EA        first checked in
  26. */
  27.  
  28.  
  29. #ifndef __LYNXFWIM__
  30. #define __LYNXFWIM__
  31.  
  32. #ifndef __TYPES__
  33. #include <Types.h>
  34. #endif
  35. #ifndef __INTERRUPTS__
  36. #include <Interrupts.h>
  37. #endif
  38.  
  39. #ifdef __cplusplus
  40. extern "C" {
  41. #endif
  42.  
  43. #if PRAGMA_IMPORT_SUPPORTED
  44. #pragma import on
  45. #endif
  46.  
  47. #if PRAGMA_ALIGN_SUPPORTED
  48. #pragma options align=power
  49. #endif
  50.  
  51. /*zzz*/
  52. /* Isn't this PCI standard stuff?  Shouldn't it be in some regular include */
  53. /* file like PCI.h? */
  54.  
  55. #define bit0            0x00000001
  56. #define bit1            0x00000002
  57. #define bit2            0x00000004
  58. #define bit3            0x00000008
  59. #define bit4            0x00000010
  60. #define bit5            0x00000020
  61. #define bit6            0x00000040
  62. #define bit7            0x00000080
  63. #define bit8            0x00000100
  64. #define bit9            0x00000200
  65. #define bit10            0x00000400
  66. #define bit11            0x00000800
  67. #define bit12            0x00001000
  68. #define bit13            0x00002000
  69. #define bit14            0x00004000
  70. #define bit15            0x00008000
  71. #define bit16            0x00010000
  72. #define bit17            0x00020000
  73. #define bit18            0x00040000
  74. #define bit19            0x00080000
  75. #define bit20            0x00100000
  76. #define bit21            0x00200000
  77. #define bit22            0x00400000
  78. #define bit23            0x00800000
  79. #define bit24            0x01000000
  80. #define bit25            0x02000000
  81. #define bit26            0x04000000
  82. #define bit27            0x08000000
  83. #define bit28            0x10000000
  84. #define bit29            0x20000000
  85. #define bit30            0x40000000
  86. #define bit31            0x80000000
  87.  
  88. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  89.  * Configuration Registers
  90.  *
  91.  */
  92. enum {
  93.     kConfigStart        = 0x00,
  94.     cwVendorID            = 0x00,            /* 0x1000                                    */
  95.     cwDeviceID            = 0x02,            /* 0x0003                                    */
  96.     cwCommand            = 0x04,
  97.     cwStatus            = 0x06,
  98.     clClassCodeAndRevID    = 0x08,
  99.     clHeaderAndLatency    = 0x0C,
  100.     clBaseAddressZero    = 0x10,            /* I/O Base address                            */
  101.     clBaseAddressOne    = 0x14,            /* Memory Base address                        */
  102.     clExpansionRomAddr    = 0x30,
  103.     clLatGntIntPinLine    = 0x3C,            /* Max_Lat, Max_Gnt, Int. Pin, Int. Line    */
  104.     kConfigEnd            = 0x40
  105. };
  106.  
  107. /*
  108.  * 0x04 cwCommand                    Command Register (read/write)
  109.  */
  110. enum {
  111.     cwCommandSERREnable            = bit8,
  112.     cwCommandEnableParityError    = bit6,
  113.     cwCommandEnableBusMaster    = bit2,        /* Set this on initialization            */
  114.     cwCommandEnableMemorySpace    = bit1,        /* Respond at Base Address One if set    */
  115.     cwCommandEnableIOSpace        = bit0        /* Respond at Base Address Zero if set    */
  116. };
  117. /*
  118.  * 0x06 cwStatus                    Status Register (read/write)
  119.  */
  120. enum {
  121.     cwStatusDetectedParityError    = bit15,    /* Detected from slave                    */
  122.     cwStatusSignaledSystemError = bit14,    /* Device asserts SERR/ signal            */
  123.     cwStatusMasterAbort             = bit13,    /* Master sets when transaction aborts    */
  124.     cwStatusReceivedTargetAbort    = bit12,    /* Master sets when target-abort        */
  125.     cwStatusDEVSELTimingMask    = (bit10 | bit9),    /* DEVSEL timing encoding R/O    */
  126.      cwStatusDEVSELFastTiming    = 0,
  127.      cwStatusDEVSELMediumTiming    = bit9,
  128.      cwStatusDEVSELSlowTiming    = bit10,
  129.     cwStatusDataParityReported    = bit8
  130. };
  131.  
  132. /*zzz*/
  133.  
  134.  
  135. ////////////////////////////////////////////////////////////////////////////////
  136. //
  137. // Useful macro defs.
  138. //
  139.  
  140. #define EndianSwapImm32Bit(data32)                    \
  141. (                                                    \
  142.     (((UInt32) data32) >> 24)                |        \
  143.     ((((UInt32) data32) >> 8) & 0xFF00)        |        \
  144.     ((((UInt32) data32) << 8) & 0xFF0000)    |        \
  145.     (((UInt32) data32) << 24)                        \
  146. )
  147.  
  148.  
  149.  
  150. ////////////////////////////////////////////////////////////////////////////////
  151. //
  152. // FWIM data defs.
  153. //
  154.  
  155. enum
  156. {    // Default channel numbers. Some of these can change
  157.     // or go away completely if more isochronous channels
  158.     // are needed.
  159.     
  160.     kAsyncDMAWriteAccel            = 0,        // For hardware acceleration of incoming block writes.
  161.                                             // can be re-used for isochronous if necessary. 
  162.     kAsyncDMAReadRxAccel        = 1,        // For hardware acceleration of incoming block writes. 
  163.                                             // can be re-used for isochronous if necessary. 
  164.     kAsyncReceiveDMA            = 2,        // Hard Coded. Needs to be LOWER priority than acceleration 
  165.                                             // otherwise this channel gets the packets instead.
  166.     kAsyncDMAReadTxAccel        = 3,        // Used in conjunction with kAsyncDMAReadRxAccel.
  167.                                             // Don't use until we are done with kDMARegisterAccess.
  168.     kAsyncTransmitDMA            = 4,        // Hard Coded. Lowest priority (would rather receive)
  169.     kDMARegisterAccess            = 4,        // Preferred channel for testing if the PHY is powered. 
  170.                                             // Shared with transmit DMA.
  171.     kNumDMAChannels                = 5,        // Number of DMA channels.
  172.     kPacketBufferSize            = 2064,        // Largest legal async packet is 2064 
  173.                                             // bytes (400 mb)
  174.     kMaxBufPage                    = 8,        // Max # of physical pages per packet
  175.     kAsyncTxDonePCL                = 0,        // Async transmit done PCL index.
  176.     kAsyncTxDummyPCL            = 1,        // Async transmit dummy PCL index.
  177.     kAsyncTxDataPCL                = 2,        // Async transmit data PCL index.
  178.     kNumAsyncTxPCLs                = 3,        // Number of PCLs for async transmit.
  179.     kAsyncRxOverrunPCL            = 0,        // Async receive overrun PCL index.
  180.     kAsyncRxDummyPCL            = 1,        // Async receive dummy PCL index.
  181.     kAsyncRxFirstPacketPCL        = 2,        // First async receive packet PCL index.
  182.     kAsyncBufs                    = 48,        // # of Async bufs
  183.     kAsyncRxLastPacketPCL        = (kAsyncBufs - 1), // Last async receive packet PCL index.
  184.     kAccelWriteDummyPCL            = 0,        // Dummy PCL which kicks off the circularly linked accleration PCL
  185.     kAccelWritePCL                = 1,        // The PCL in circularly linked list which does the work
  186.     kAccelReadDummyPCL            = 0,        // Dummy PCL which kicks off the circularly linked accleration PCL
  187.     kAccelReadPCLThrottle        = 1,        // The PCL that pays attention to the busy bit
  188.     kAccelReadPCLSpeedSort        = 2,        // The PCL in Tx circularly linked list which figures out what speed the incoming packet came in at
  189.     kAccelReadRxPCL                = 1,        // The PCL in Rx circularly linked list which does the work
  190.     kAccelReadTxPCL                = 3,        // The PCL in Tx circularly linked list which does the work
  191.     kAccelReadRxPCLAux            = 2,        // The Aux PCL which turns channels on and off to keep Rx and Tx in Sync
  192.     kAccelReadTxPCLAux            = 6,        // The Aux PCL which turns channels on and off to keep Rx and Tx in Sync
  193.     kAccelReadTxPCLDone            = 7,        // The Aux PCL which Clears Busy and stops the channel
  194.     kRegAccessDummyPCL            = 0,        // Offset of Reg Access Dummy PCL.
  195.     kRegAccessPCL                = 1            // Offset of Reg Access PCL.
  196. };
  197.  
  198.  
  199. // Strictly speaking, the "Lynx PHY" is the TSB21LV03.
  200. // If PCI-Lynx is used with another PHY, these constants may change.
  201. // These are all the same as the old TSB11C01DL PHY from the P1394 card.
  202. //
  203. // I'm now adding support for the TSB41LV06 (6 ports, 400Mb, 1394a) as well.
  204. // Hopefully this makes it more general as well. -DCB
  205.  
  206. ////////////////////////////////////////////////////////////////////////////////
  207. //
  208. // Phy registers.
  209. //
  210.  
  211. enum
  212. {
  213.     kLynxPhyBit0                = (1 << 7),
  214.     kLynxPhyBit1                = (1 << 6),
  215.     kLynxPhyBit2                = (1 << 5),
  216.     kLynxPhyBit3                = (1 << 4),
  217.     kLynxPhyBit4                = (1 << 3),
  218.     kLynxPhyBit5                = (1 << 2),
  219.     kLynxPhyBit6                = (1 << 1),
  220.     kLynxPhyBit7                = (1 << 0)
  221. };
  222.  
  223. #define LynxPhyBitRange(start, end)                    \
  224. (                                                    \
  225.     (((((UInt32) 0xFF) << (start)) & 0xFF) >>        \
  226.      ((start) + (7 - (end)))) <<                    \
  227.     (7 - (end))                                        \
  228. )
  229.  
  230. #define LynxPhyBitRangePhase(start, end)            \
  231.     (7 - end)
  232.  
  233. // Phy register defs.
  234.  
  235. // 1394 (TSB21LV03) PHY with old register set
  236. enum
  237. {
  238.     kLynxPhyPhysicalIDAddress    = 0,
  239.     kLynxPhyPhysicalID            = LynxPhyBitRange (0, 5),
  240.     kLynxPhyPhysicalIDPhase        = LynxPhyBitRangePhase (0, 5),
  241.  
  242.     kLynxPhyRAddress            = 0,
  243.     kLynxPhyR                    = kLynxPhyBit6,
  244.  
  245.     kLynxPhyCPSAddress            = 0,
  246.     kLynxPhyCPS                    = kLynxPhyBit7,
  247.  
  248.     kLynxPhyRHBAddress            = 1,
  249.     kLynxPhyRHB                    = kLynxPhyBit0,
  250.  
  251.     kLynxPhyIBRAddress            = 1,
  252.     kLynxPhyIBR                    = kLynxPhyBit1,
  253.  
  254.     kLynxPhyGCAddress            = 1,
  255.     kLynxPhyGC                    = LynxPhyBitRange (2, 7),
  256.     kLynxPhyGCPhase                = LynxPhyBitRangePhase (2, 7),
  257.  
  258.     kLynxPhySPDAddress            = 2,
  259.     kLynxPhySPD                    = LynxPhyBitRange (0, 1),
  260.     kLynxPhySPDPhase            = LynxPhyBitRangePhase (0, 1),
  261.  
  262.     kLynxPhyNPAddress            = 2,
  263.     kLynxPhyNP                    = LynxPhyBitRange (3, 7),
  264.     kLynxPhyNPPhase                = LynxPhyBitRangePhase (3, 7),
  265.  
  266.     kLynxPhyPortStatusAddress    = 3,
  267.     kLynxPhyAStat                = LynxPhyBitRange (0, 1),
  268.     kLynxPhyAStatPhase            = LynxPhyBitRangePhase (0, 1),
  269.  
  270.     kLynxPhyBStat                = LynxPhyBitRange (2, 3),
  271.     kLynxPhyBStatPhase            = LynxPhyBitRangePhase (2, 3),
  272.  
  273.     kLynxPhyPortStatus            = LynxPhyBitRange (4, 5),
  274.     kLynxPhyPortStatusPhase        = LynxPhyBitRangePhase (4, 5),
  275.     kLynxPhyCh                    = kLynxPhyBit4,
  276.     kLynxPhyCon                    = kLynxPhyBit5,
  277.  
  278.     kLynxPhyCAddress            = 6,
  279.     kLynxPhyC                    = kLynxPhyBit7,
  280.  
  281.     kLynxPhyInvalidAddress        = 15
  282. };
  283.  
  284.  
  285.  
  286. // 1394a (TSB41LV06) PHY with Extended Register Set 
  287. enum 
  288. {
  289.     kLynxExtPhyPhysicalIDAddress    = 0,
  290.     kLynxExtPhyPhysicalID            = LynxPhyBitRange (0, 5),
  291.     kLynxExtPhyPhysicalIDPhase        = LynxPhyBitRangePhase (0, 5),
  292.  
  293.     kLynxExtPhyRAddress                = 0,
  294.     kLynxExtPhyR                    = kLynxPhyBit6,
  295.  
  296.     kLynxExtPhyCPSAddress            = 0,
  297.     kLynxExtPhyCPS                    = kLynxPhyBit7,
  298.  
  299.     kLynxExtPhyRHBAddress            = 1,
  300.     kLynxExtPhyRHB                    = kLynxPhyBit0,
  301.  
  302.     kLynxExtPhyIBRAddress            = 1,
  303.     kLynxExtPhyIBR                    = kLynxPhyBit1,
  304.  
  305.     kLynxExtPhyGCAddress            = 1,
  306.     kLynxExtPhyGC                    = LynxPhyBitRange (2, 7),
  307.     kLynxExtPhyGCPhase                = LynxPhyBitRangePhase (2, 7),
  308.     
  309.     kLynxExtPhyExtAddress            = 2,
  310.     kLynxExtPhyExt                    = LynxPhyBitRange (0, 2),
  311.     kLynxExtPhyExtPhase                = LynxPhyBitRangePhase (0, 2),
  312.     
  313.     kLynxExtPhyNPAddress            = 2,
  314.     kLynxExtPhyNP                    = LynxPhyBitRange (3, 7),
  315.     kLynxExtPhyNPPhase                = LynxPhyBitRangePhase (3, 7),
  316.  
  317.     kLynxExtPhySPDAddress            = 3,
  318.     kLynxExtPhySPD                    = LynxPhyBitRange (0, 1),
  319.     kLynxExtPhySPDPhase                = LynxPhyBitRangePhase (0, 1),
  320.     
  321.     kLynxExtPhyLinkAddress            = 4,
  322.     kLynxExtPhyLink                    = kLynxPhyBit0,
  323.  
  324.     kLynxExtPhyCntdAddress            = 4,
  325.     kLynxExtPhyCntd                    = kLynxPhyBit1,
  326.  
  327.     kLynxExtPhyDlyAddress            = 4,
  328.     kLynxExtPhyDly                    = LynxPhyBitRange (2, 3),
  329.     kLynxExtPhyDlyPhase                = LynxPhyBitRangePhase (2, 3),
  330.  
  331.     kLynxExtPhyIRAddress            = 4,
  332.     kLynxExtPhyIR                    = kLynxPhyBit4,
  333.  
  334.     kLynxExtPhyPwrAddress            = 4,
  335.     kLynxExtPhyPwr                    = LynxPhyBitRange (5, 7),
  336.     kLynxExtPhyPwrPhase                = LynxPhyBitRangePhase (5, 7),
  337.  
  338.     kLynxExtPhyISBRAddress            = 5,
  339.     kLynxExtPhyISBR                    = kLynxPhyBit1,
  340.  
  341.     kLynxExtPhyCTOIAddress            = 5,
  342.     kLynxExtPhyCTOI                    = kLynxPhyBit2,
  343.  
  344.     kLynxExtPhyCPSIAddress            = 5,
  345.     kLynxExtPhyCPSI                    = kLynxPhyBit3,
  346.  
  347.     kLynxExtPhySTOIAddress            = 5,
  348.     kLynxExtPhySTOI                    = kLynxPhyBit4,
  349.  
  350.     kLynxExtPhyDPSIAddress            = 5,
  351.     kLynxExtPhyDPSI                    = kLynxPhyBit5,
  352.  
  353.     kLynxExtPhyEAAAddress            = 5,
  354.     kLynxExtPhyEAA                    = kLynxPhyBit6,
  355.  
  356.     kLynxExtPhyEMSCAddress            = 5,
  357.     kLynxExtPhyEMSC                    = kLynxPhyBit7,
  358.  
  359.     kLynxExtPhyPingAddres            = 6,
  360.     kLynxExtPhyPing                    = LynxPhyBitRange (0, 7),
  361.     kLynxExtPhyPingPhase            = LynxPhyBitRangePhase (0, 7),
  362.     
  363.     kLynxExtPhyPortAddres            = 7,
  364.     kLynxExtPhyPort                    = LynxPhyBitRange (3, 7),
  365.     kLynxExtPhyPortPhase            = LynxPhyBitRangePhase (3, 7),
  366.     
  367.     kLynxExtPhyAStatnAddress        = 8,
  368.     kLynxExtPhyAStatn                = LynxPhyBitRange (0, 1),
  369.     kLynxExtPhyAStatnPhase            = LynxPhyBitRangePhase (0, 1),
  370.  
  371.     kLynxExtPhyBStatnAddress        = 8,
  372.     kLynxExtPhyBStatn                = LynxPhyBitRange (2, 3),
  373.     kLynxExtPhyBStatnPhase            = LynxPhyBitRangePhase (2, 3),
  374.  
  375.     kLynxExtPhyPortStatusnAddress    = 8,
  376.     kLynxExtPhyPortStatusn            = LynxPhyBitRange (4, 5),
  377.     kLynxExtPhyPortStatusnPhase        = LynxPhyBitRangePhase (4, 5),
  378.  
  379.     kLynxExtPhyChnAddress            = 8,
  380.     kLynxExtPhyChn                    = kLynxPhyBit4,
  381.  
  382.     kLynxExtPhyConnAddress            = 8,
  383.     kLynxExtPhyConn                    = kLynxPhyBit5,
  384.  
  385.     kLynxExtPhyBiasnAddress            = 8,
  386.     kLynxExtPhyBiasn                = kLynxPhyBit6,
  387.  
  388.     kLynxExtPhyDisnAddress            = 8,
  389.     kLynxExtPhyDisn                    = kLynxPhyBit7,
  390.  
  391.     kLynxExtPhyPeerSpdnAddress        = 9,
  392.     kLynxExtPhyPeerSpdn                = LynxPhyBitRange (0, 1),
  393.     kLynxExtPhyPeerSpdnPhase        = LynxPhyBitRangePhase (0, 1),
  394.  
  395.     kLynxExtPhyInvalidAddress        = 10
  396. };
  397.  
  398.  
  399. ////////////////////////////////////////////////////////////////////////////////
  400. //
  401. // Lynx register file.
  402. //
  403.  
  404. enum
  405. {
  406.     kLynxBit0                    = (1 << 0),
  407.     kLynxBit1                    = (1 << 1),
  408.     kLynxBit2                    = (1 << 2),
  409.     kLynxBit3                    = (1 << 3),
  410.     kLynxBit4                    = (1 << 4),
  411.     kLynxBit5                    = (1 << 5),
  412.     kLynxBit6                    = (1 << 6),
  413.     kLynxBit7                    = (1 << 7),
  414.     kLynxBit8                    = (1 << 8),
  415.     kLynxBit9                    = (1 << 9),
  416.     kLynxBit10                    = (1 << 10),
  417.     kLynxBit11                    = (1 << 11),
  418.     kLynxBit12                    = (1 << 12),
  419.     kLynxBit13                    = (1 << 13),
  420.     kLynxBit14                    = (1 << 14),
  421.     kLynxBit15                    = (1 << 15),
  422.     kLynxBit16                    = (1 << 16),
  423.     kLynxBit17                    = (1 << 17),
  424.     kLynxBit18                    = (1 << 18),
  425.     kLynxBit19                    = (1 << 19),
  426.     kLynxBit20                    = (1 << 20),
  427.     kLynxBit21                    = (1 << 21),
  428.     kLynxBit22                    = (1 << 22),
  429.     kLynxBit23                    = (1 << 23),
  430.     kLynxBit24                    = (1 << 24),
  431.     kLynxBit25                    = (1 << 25),
  432.     kLynxBit26                    = (1 << 26),
  433.     kLynxBit27                    = (1 << 27),
  434.     kLynxBit28                    = (1 << 28),
  435.     kLynxBit29                    = (1 << 29),
  436.     kLynxBit30                    = (1 << 30),
  437.     kLynxBit31                    = (1 << 31)
  438. };
  439.  
  440. #define LynxBitRange(start, end)                    \
  441. (                                                    \
  442.     ((((UInt32) 0xFFFFFFFF) << (31 - (end))) >>        \
  443.      ((31 - (end)) + (start))) <<                    \
  444.     (start)                                            \
  445. )
  446.  
  447. #define LynxBitRangePhase(start, end)                \
  448.     (start)
  449.  
  450.  
  451. // As far as I can tell these are all 1394 constants
  452. // I think they could be moved to FireWire.h
  453. // Link Data Format defs.
  454. // (Erik's note: actually, these are supposed to be FWIM specific,
  455. // but for some reason, I didn't name them that way.  We should change
  456. // the names to kLynx...
  457.  
  458. enum
  459. {
  460.     kLynxTCodeSelfID            = 16
  461. };
  462.  
  463. enum
  464. {
  465.     kFWPacketTCode                = FWBitRange (24, 27),
  466.     kFWPacketTCodePhase            = FWBitRangePhase (24, 27)
  467. };
  468.  
  469.  
  470. enum
  471. {
  472.     kFWAsynchSpd                = FWBitRange (14, 15),
  473.     kFWAsynchSpdPhase            = FWBitRangePhase (14, 15),
  474.  
  475.     kFWAsynchTLabel                = FWBitRange (16, 21),
  476.     kFWAsynchTLabelPhase        = FWBitRangePhase (16, 21),
  477.  
  478.     kFWAsynchRt                    = FWBitRange (22, 23),
  479.     kFWAsynchRtPhase            = FWBitRangePhase (22, 23),
  480.     kFWAsynchNew                = 0,
  481.     kFWAsynchRetryA                = 2,
  482.     kTIAsycnhRetryB                = 3,
  483.  
  484.     kFWAsynchPriority            = FWBitRange (28, 31),
  485.     kFWAsynchPriorityPhase        = FWBitRangePhase (28, 31),
  486.  
  487.     kFWAsynchDestinationID        = FWBitRange (0, 15),
  488.     kFWAsynchDestinationIDPhase    = FWBitRangePhase (0, 15),
  489.  
  490.     kFWAsynchSourceID            = FWBitRange (0, 15),
  491.     kFWAsynchSourceIDPhase        = FWBitRangePhase (0, 15),
  492.  
  493.     kFWAsynchDestinationOffsetHigh    = FWBitRange (16, 31),
  494.     kFWAsynchDestinationOffsetHighPhase    = FWBitRangePhase (16, 31),
  495.  
  496.     kFWAsynchDestinationOffsetLow    = FWBitRange (0, 31),
  497.     kFWAsynchDestinationOffsetLowPhase    = FWBitRangePhase (0, 31),
  498.  
  499.     kFWAsynchDataLength            = FWBitRange (0, 15),
  500.     kFWAsynchDataLengthPhase    = FWBitRangePhase (0, 15),
  501.  
  502.     kFWAsynchExtendedTCode        = FWBitRange (16, 31),
  503.     kFWAsynchExtendedTCodePhase    = FWBitRangePhase (16, 31),
  504.  
  505.     kFWAsynchAckSent            = FWBitRange (28, 31),
  506.     kFWAsynchAckSentPhase        = FWBitRangePhase (28, 31),
  507.  
  508.     kFWAsynchRCode                = FWBitRange (16, 19),
  509.     kFWAsynchRCodePhase            = FWBitRangePhase (16, 19)
  510. };
  511.  
  512. enum
  513. {
  514.     kLynxIsochTCode                = LynxBitRange (4, 7),
  515.     kLynxIsochTCodePhase        = LynxBitRangePhase (4, 7),
  516.  
  517.     kLynxIsochTag                = LynxBitRange (14, 15),
  518.     kLynxIsochTagPhase            = LynxBitRangePhase (14, 15),
  519.  
  520.     kLynxIsochErrCode            = FWBitRange (28, 31),
  521.     kLynxIsochErrCodePhase        = FWBitRangePhase (28, 31)
  522. };
  523.  
  524.  
  525. // Lynx DMA Packet Control List
  526. // (not part of register file, but pointed to by next struct)
  527.  
  528. struct LynxPCLBufferStruct
  529. {
  530.     UInt32                        control;
  531.     UInt32                        *address;
  532. };
  533. typedef struct LynxPCLBufferStruct        LynxPCLBuffer, *LynxPCLBufferPtr;
  534.  
  535. struct LynxPCLStruct
  536. {
  537.     UInt32                        *nextPCL;
  538.     UInt32                        *nextPCLAlt;
  539.     UInt32                        refCon;
  540.     UInt32                        status;
  541.     UInt32                        remaining;
  542.     UInt32                        *nextAddress;
  543.     LynxPCLBuffer                buffer[13];
  544. };
  545. typedef struct LynxPCLStruct        LynxPCL, *LynxPCLPtr;
  546.  
  547. // Lynx DMA channel structure
  548. // (one in register file for each channel)
  549.  
  550. struct LynxChannelStruct
  551. {
  552.     volatile UInt32                prevPCLAddrTemp;
  553.     volatile UInt32                curPCLAddr;
  554.     volatile UInt32                curDataBufferAddr;
  555.     volatile UInt32                status;
  556.     volatile UInt32                control;
  557.     volatile UInt32                ready;
  558.     volatile UInt32                curState;
  559.     volatile UInt32                reserved1C;
  560. };
  561. typedef struct LynxChannelStruct        LynxChannel, *LynxChannelPtr;
  562.  
  563. // Constants used in Lynx PCLs and some DMA registers
  564.  
  565. enum
  566. {
  567.     kLynxDMA_NOP                = 0,
  568.     kLynxDMA_RCV                = 1,
  569.     kLynxDMA_XMT                = 2,
  570.     kLynxDMA_LOAD                = 3,
  571.     kLynxDMA_STORE_QUAD            = 4,
  572.     kLynxDMA_STORE0                = 5,
  573.     kLynxDMA_STORE1                = 6,
  574.     kLynxDMA_BRANCH                = 7,
  575.     kLynxDMA_PCI_TO_LBUS        = 8,
  576.     kLynxDMA_LBUS_TO_PCI        = 9,
  577.     kLynxDMA_RCV_AND_UPDATE        = 10,
  578.     kLynxDMA_STORE_DOUBLE        = 11,
  579.     kLynxDMA_UNFORMATTED_XMT    = 12,
  580.     kLynxDMA_ADD                = 13,
  581.     kLynxDMA_COMPARE            = 14
  582. };
  583.  
  584. enum
  585. {
  586.     kLynxDMAWaitNone            = 0,
  587.     kLynxDMAWaitReady1            = 1,
  588.     kLynxDMAWaitReady0            = 2,
  589.     kLynxDMAWaitExternal1        = 3,
  590.     kLynxDMAWaitExternal0        = 4,
  591.     kLynxDMAWaitGPIO2            = 5,
  592.     kLynxDMAWaitGPIO3            = 6,
  593.     kLynxDMAWaitReserved        = 7
  594. };
  595.  
  596. enum
  597. {
  598.     kLynxDMA100mbps                = 0,
  599.     kLynxDMA200mbps                = 1,
  600.     kLynxDMA400mbps                = 2
  601. };
  602.  
  603. enum
  604. {
  605.     kLynxAuxPCLCompareEnable    = LynxBitRange (16, 31),
  606.     kLynxAuxPCLCompareEnablePhase    = LynxBitRangePhase (16, 31),
  607.     
  608.     kLynxAuxPCLCompareValue        = LynxBitRange (0, 15),
  609.     kLynxAuxPCLCompareValuePhase    = LynxBitRangePhase (0, 15)
  610. };
  611.  
  612. enum
  613. {
  614.     kLynxAuxConditionNone        = 0,
  615.     kLynxAuxConditionDMAReady1    = 1,
  616.     kLynxAuxConditionDMAReady0    = 2,
  617.     kLynxAuxConditionExtReady1    = 3,
  618.     kLynxAuxConditionExtReady0    = 4,
  619.     kLynxAuxConditionGPIO2Active    = 5,
  620.     kLynxAuxConditionGPIO3Active    = 6
  621. };
  622.  
  623. // Lynx DMA channel comparator structure
  624. // (one in register file for each channel)
  625.  
  626. struct LynxComparatorStruct
  627. {
  628.     volatile UInt32                value0;
  629.     volatile UInt32                mask0;
  630.     volatile UInt32                value1;
  631.     volatile UInt32                mask1;
  632. };
  633. typedef struct LynxComparatorStruct        LynxComparator, *LynxComparatorPtr;
  634.  
  635. // FIFO size and threshold defs.
  636. //
  637. // 0x00 / 0x80 / 0x80 rarely overflows or underruns
  638. //
  639. // 0x80 / 0x40 / 0x40 seems to work for isochronous transmit
  640. //
  641.     
  642.  
  643. enum
  644. {
  645.     kDefaultITFSize                = 0x00,
  646.     kDefaultITFThreshold        = 0xFF,
  647.  
  648.     kDefaultATFSize                = 0x80,
  649.     kDefaultATFThreshold        = 0x77,
  650.     
  651.     kDefaultGRFSize                = 0x80,
  652.  
  653.     kIsochTransmitModeITFSize    = 0x80,
  654.     kIsochTransmitModeITFThreshold    = 0x17,
  655.     
  656.     kIsochTransmitModeATFSize    = 0x40,
  657.     kIsochTransmitModeATFThreshold    = 0x37,
  658.     
  659.     kIsochTransmitModeGRFSize    = 0x40
  660. };
  661.  
  662.  
  663. // Stuff for the serial EEPROM
  664.  
  665. enum
  666. {
  667.     kLynxMinEEPROMQuads                    = 64,            // 256 bytes / 2048 bits
  668.     kLynxMaxEEPROMQuads                    = 512,            // 2048 bytes / 16384 bits
  669.     
  670.     kLynxEEPROMKeyModuleVendorID        = 0x03,
  671.     kLynxEEPROMKeyModuleHardwareVersion    = 0x04,
  672.     kLynxEEPROMKeyNodeHardwareVersion    = 0x09,
  673.     kLynxEEPROMKeyModuleDependentInfo    = 0xc7,
  674.     kLynxEEPROMKeySramQuads                = 0x39,
  675.     kLynxEEPROMKeyAuxRamQuads            = 0x3a,
  676.     kLynxEEPROMKeyAuxDevice                = 0x3b,
  677.     
  678.     kClockHi                            = 1,            // These are supposed to make
  679.     kClockLo                            = 0,            // the code easier to read.
  680.     kDataHi                                = 1,            // Putting "LynxEEPROMControl"
  681.     kDataLo                                = 0,            // in each one would not help.
  682.     kNoData                                = 2,
  683.     kStartTimer                            = 1,
  684.     kNoTimer                            = 0
  685. };
  686.  
  687.  
  688. // This is the raw data in the EEPROM, up to the Root directory
  689. // These names are probably not standard
  690.  
  691. struct LynxEEPROMBaseStruct
  692. {
  693.     UInt32                        pciConfig[4];        // Details unknown, but bytes 3..6 == PCI ID 104c,8003
  694.     UInt8                        infoLen;
  695.     UInt8                        crcLen;
  696.     UInt16                        crc;
  697.     UInt32                        busInfoBlock[4];
  698.     UInt32                        romData[kLynxMaxEEPROMQuads];
  699. };
  700. typedef struct LynxEEPROMBaseStruct        LynxEEPROMBase, *LynxEEPROMBasePtr;
  701.  
  702.  
  703. // This is data derived from the EEPROM.  Technically the location
  704. // within the EEPROM could vary from chip to chip, so extract it here.
  705.  
  706. struct LynxEEPROMInfoStruct
  707. {
  708.     UInt32                        busInfoBlock[4];
  709.     UInt32                        module_Vendor_Id;
  710.     UInt32                        module_Hardware_Version;
  711.     UInt32                        node_Hardware_Version;
  712.     UInt32                        sram_Quads;
  713.     UInt32                        auxRam_Quads;
  714.     UInt32                        aux_Device;
  715. };
  716. typedef struct LynxEEPROMInfoStruct        LynxEEPROMInfo, *LynxEEPROMInfoPtr;
  717.  
  718.  
  719. // Lynx register file
  720.  
  721. struct LynxRegistersStruct
  722. {
  723.     volatile UInt32                configID;
  724.     volatile UInt32                configStatusCommand;
  725.     volatile UInt32                configClassRevID;
  726.     volatile UInt32                configControlInfo;
  727.     volatile UInt32                lynxBase;
  728.     volatile UInt32                sramBase;            // if any
  729.     volatile UInt32                auxRamBase;            // if any
  730.     volatile UInt32                reserved01C;
  731.     volatile UInt32                reserved020;
  732.     volatile UInt32                reserved024;
  733.     volatile UInt32                reserved028;
  734.     volatile UInt32                configSubSystem;
  735.     volatile UInt32                rplROMBase;
  736.     volatile UInt32                reserved034;
  737.     volatile UInt32                reserved038;
  738.     volatile UInt32                interruptMisc;
  739.     volatile UInt32                miscControl;
  740.     volatile UInt32                serialEEPROMControl;
  741.     volatile UInt32                pciInterruptStatus;
  742.     volatile UInt32                pciInterruptEnable;
  743.     volatile UInt32                pciTest;
  744.     volatile UInt32                reserved054thru0AC[23];
  745. // 0x0B0
  746.     volatile UInt32                localBusControl;
  747.     volatile UInt32                localBusAddress;
  748.     volatile UInt32                gpioControlA;
  749.     volatile UInt32                gpioControlB;
  750.     volatile UInt32                gpioData[16];        // will define if needed
  751. // 0x100
  752.     LynxChannel                    dmaChannel[64];        // only 0..4 valid
  753. // 0x900
  754.     volatile UInt32                dmaDiagTest;
  755.     volatile UInt32                dmaReceiveCount;
  756.     volatile UInt32                dmaGlobal;
  757.     volatile UInt32                reserved90cthruA00[61];
  758. // 0xA00
  759.     volatile UInt32                fifoSize;
  760.     volatile UInt32                pciFifoPort;
  761.     volatile UInt32                linkFifoPort;
  762.     volatile UInt32                fifoControlStatus;
  763.     volatile UInt32                fifoControlEnableAndTest;
  764.     volatile UInt32                fifoTransmitThreshold;
  765.     volatile UInt32                reservedA18;
  766.     volatile UInt32                reservedA1C;
  767.     volatile UInt32                grfPopPush0;
  768.     volatile UInt32                grfPopPush1;
  769.     volatile UInt32                reservedA28;
  770.     volatile UInt32                reservedA2C;
  771.     volatile UInt32                atfPopPush0;
  772.     volatile UInt32                atfPopPush1;
  773.     volatile UInt32                reservedA38;
  774.     volatile UInt32                reservedA3C;
  775.     volatile UInt32                itfPopPush0;
  776.     volatile UInt32                itfPopPush1;
  777.     volatile UInt32                reservedA48thruAFC[46];
  778. // 0xB00
  779.     LynxComparator                dmaComparator[64];    // only 0..4 valid
  780. // 0xF00
  781.     volatile UInt32                busNumberNodeNumber;
  782.     volatile UInt32                linkControl;
  783.     volatile UInt32                cycleTimer;
  784.     volatile UInt32                phyControl;
  785.     volatile UInt32                diagTestControl;
  786.     volatile UInt32                linkInterruptStatus;
  787.     volatile UInt32                linkInterruptEnable;
  788.     volatile UInt32                retryCountInterval;
  789.     volatile UInt32                stateMachineVectorMonitor;
  790.     volatile UInt32                fifoOverUnderErrorCounters;
  791. // length 0xF28
  792. };
  793. typedef struct LynxRegistersStruct        LynxRegisters, *LynxRegistersPtr;
  794.  
  795.  
  796. // Enums for selected registers, etc.
  797.  
  798. // miscControl register
  799.  
  800. enum
  801. {
  802.     kLynxMAXRTY_CNT                = LynxBitRange (12, 15),
  803.     kLynxMAXRTY_CNTPhase        = LynxBitRangePhase (12, 15),
  804.     kLynxENA_MST_RTY            = kLynxBit11,
  805.     kLynxENA_POST_WR            = kLynxBit7,
  806.     kLynxENA_SLV_BURST            = kLynxBit6,
  807.     kLynxPAUSE_MSTR                = kLynxBit3,
  808.     kLynxAUTOBOOT_IN            = kLynxBit2,
  809.     kLynxSET_FORCE_INT            = kLynxBit1,
  810.     kLynxSWRST                    = kLynxBit0
  811. };
  812.  
  813. // serialEEPROMControl register
  814.  
  815. enum
  816. {
  817.     kLynxEEPERR                    = kLynxBit9,
  818.     kLynxEEPCHKERR                = kLynxBit8,
  819.     kLynxNOTPRS                    = kLynxBit7,
  820.     kLynxEEPCLK                    = kLynxBit6,
  821.     kLynxEEPENA                    = kLynxBit5,
  822.     kLynxEEPDAT                    = kLynxBit4,
  823.     kLynxEEPSTARTRD                = kLynxBit2,
  824.     kLynxTIMER_5USEC            = kLynxBit0
  825. };
  826.  
  827. // pciInterruptStatus and pciInterruptEnable
  828.  
  829. enum
  830. {
  831.     kLynxINT_PEND                = kLynxBit31,
  832.     kLynxFRC_INT                = kLynxBit30,
  833.     kLynxSLV_ADR_PERR            = kLynxBit28,
  834.     kLynxSLV_DAT_PERR            = kLynxBit27,
  835.     kLynxMST_DAT_PERR            = kLynxBit26,
  836.     kLynxMST_DEV_TO                = kLynxBit25,
  837.     kLynxMST_RETRY_TO            = kLynxBit24,
  838.     kLynxINTERNAL_SLV_TO        = kLynxBit23,
  839.     kLynxAUX_TO                    = kLynxBit18,
  840.     kLynxAUX_INT                = kLynxBit17,
  841.     kLynxP1394_INT                = kLynxBit16,
  842.     kLynxDMA4_PCL                = kLynxBit9,
  843.     kLynxDMA4_HLT                = kLynxBit8,
  844.     kLynxDMA3_PCL                = kLynxBit7,
  845.     kLynxDMA3_HLT                = kLynxBit6,
  846.     kLynxDMA2_PCL                = kLynxBit5,
  847.     kLynxDMA2_HLT                = kLynxBit4,
  848.     kLynxDMA1_PCL                = kLynxBit3,
  849.     kLynxDMA1_HLT                = kLynxBit2,
  850.     kLynxDMA0_PCL                = kLynxBit1,
  851.     kLynxDMA0_HLT                = kLynxBit0
  852. };
  853.  
  854. // some missing
  855.  
  856. // GPIO Control Register A and B
  857.  
  858. enum
  859. {
  860.     kLynxGPIO_OUT_EN0            = kLynxBit0,
  861.     kLynxGPIO_POL_OUT0            = kLynxBit2,
  862.     kLynxGPIO_SRC0                = LynxBitRange (8, 12),
  863.     kLynxGPIO_SRC0Phase            = LynxBitRangePhase (8, 12),
  864.  
  865.     kLynxGPIO_OUT_EN1            = kLynxBit16,
  866.     kLynxGPIO_POL_OUT1            = kLynxBit18,
  867.     kLynxGPIO_SRC1                = LynxBitRange (24, 28),
  868.     kLynxGPIO_SRC1Phase            = LynxBitRangePhase (24, 28),
  869.  
  870.     kLynxGPIO_OUT_EN2            = kLynxBit0,
  871.     kLynxGPIO_POL_OUT2            = kLynxBit2,
  872.     kLynxGPIO_SRC2                = LynxBitRange (8, 12),
  873.     kLynxGPIO_SRC2Phase            = LynxBitRangePhase (8, 12),
  874.  
  875.     kLynxGPIO_OUT_EN3            = kLynxBit16,
  876.     kLynxGPIO_POL_OUT3            = kLynxBit18,
  877.     kLynxGPIO_SRC3                = LynxBitRange (24, 28),
  878.     kLynxGPIO_SRC3Phase            = LynxBitRangePhase (24, 28)
  879.  
  880. };
  881.  
  882. // DMA Channel Current Packect control List Address
  883.  
  884. enum
  885. {
  886.     kLynxCPLADR                    = LynxBitRange (1, 31),
  887.     kLynxCPLADRPhase            = LynxBitRangePhase (1, 31),
  888.     kLynxCPLVALID                = kLynxBit0,
  889.     kLynxCPLINVALID                = kLynxBit0            // TI named it backwards (1 == invalid)
  890. };
  891.  
  892. // DMA Channel status
  893.  
  894. enum
  895. {
  896.     kLynxInvalidStatus            = kLynxBit0,
  897.  
  898.     kLynxISO_MODE                = kLynxBit30,
  899.     kLynxMstErr                    = kLynxBit29,
  900.     kLynxPktErr                    = kLynxBit28,
  901.     kLynxPktCmp                    = kLynxBit27,
  902.     kLynxReceiveDma_Cha            = LynxBitRange (21, 26),
  903.     kLynxReceiveDma_ChaPhase    = LynxBitRangePhase (21, 26),
  904.     kLynxRcv_Speed                = LynxBitRange (19, 20),
  905.     kLynxRcv_SpeedPhase            = LynxBitRangePhase (19, 20),
  906.     kLynxAcks                    = LynxBitRange (15, 18),
  907.     kLynxAcksPhase                = LynxBitRangePhase (15, 18),
  908.     kLynxAck_Type                = kLynxBit14,
  909.     kLynxTransferredCount        = LynxBitRange (0, 12),
  910.     kLynxTransferredCountPhase    = LynxBitRangePhase (0, 12)
  911. };
  912.  
  913. // DMA channel control
  914.  
  915. enum
  916. {
  917.     kLynxDMA_CH_ENA                = kLynxBit31,
  918.     kLynxDMA_BSY                = kLynxBit30,
  919.     kLynxDMA_LINK                = kLynxBit29,
  920.     kLynxDMA_CMD                = LynxBitRange (24, 27),
  921.     kLynxDMA_CMDPhase            = LynxBitRangePhase (24, 27),
  922.     kLynxDMA_WAIT_SEL            = LynxBitRange (20, 22),
  923.     kLynxDMA_WAIT_SELPhase        = LynxBitRangePhase (20, 22),
  924.     kLynxDMA_BRANCH_SEL            = LynxBitRange (20, 22),
  925.     kLynxDMA_BRANCH_SELPhase    = LynxBitRangePhase (20, 22),
  926.     kLynxDMA_INT                = kLynxBit19,
  927.     kLynxDMA_LAST_BUF            = kLynxBit18,
  928.     kLynxDMA_WAIT_FOR_STATUS    = kLynxBit17,
  929.     kLynxDMA_BIG_ENDIAN            = kLynxBit16,
  930.     kLynxDMA_xmit_spd_code        = LynxBitRange (14, 15),
  931.     kLynxDMA_xmit_spd_codePhase    = LynxBitRangePhase (14, 15),
  932.     kLynxDMA_Multi_ISO            = kLynxBit13,
  933.     kLynxDMA_Tramsmit_ISO        = kLynxBit12,
  934.     kLynxDMA_TransferCount        = LynxBitRange (0, 11),
  935.     kLynxDMA_TransferCountPhase    = LynxBitRangePhase (0, 11)
  936. };
  937.  
  938. // DMA ready
  939.  
  940. enum
  941. {
  942.     kLynxDMAReadyCONDITION        = kLynxBit0
  943. };
  944.  
  945. // DMA state
  946.  
  947. // etc
  948.  
  949. // FIFO Size
  950.  
  951. enum
  952. {
  953.     kLynxITF_FIFOSZ                = LynxBitRange (16, 23),
  954.     kLynxITF_FIFOSZPhase        = LynxBitRangePhase (16, 23),
  955.     kLynxATF_FIFOSZ                = LynxBitRange (8, 15),
  956.     kLynxATF_FIFOSZPhase        = LynxBitRangePhase (8, 15),
  957.     kLynxGRF_FIFOSZ                = LynxBitRange (0, 7),
  958.     kLynxGRF_FIFOSZPhase        = LynxBitRangePhase (0, 7)
  959. };
  960.  
  961. // FIFO index read/write port [dangerous to write]
  962.  
  963. enum
  964. {
  965.     kLynxITF_WAB                = kLynxBit26,
  966.     kLynxATF_WAB                = kLynxBit25,
  967.     kLynxGRF_WAB                = kLynxBit24,
  968.     kLynxITF_PTR                = LynxBitRange (16, 23),
  969.     kLynxITF_PTRPhase            = LynxBitRangePhase (16, 23),
  970.     kLynxATF_PTR                = LynxBitRange (8, 15),
  971.     kLynxATF_PTRPhase            = LynxBitRangePhase (8, 15),
  972.     kLynxGRF_PTR                = LynxBitRange (0, 7),
  973.     kLynxGRF_PTRPhase            = LynxBitRangePhase (0, 7)
  974. };
  975.  
  976. // FIFO Control Token Status
  977.  
  978. enum
  979. {
  980.     kLynxGRF_FCT32                = kLynxBit1,
  981.     kLynxTF_FCT32                = kLynxBit0
  982. };
  983.  
  984. // FIFO Control and test Register
  985.  
  986. enum
  987. {
  988.     kLynxTEXT_MUX                = LynxBitRange (8, 11),
  989.     kLynxTEXT_MUXPhase            = LynxBitRangePhase (8, 11),
  990.     kLynxGRF_FLUSH                = kLynxBit4,
  991.     kLynxITF_FLUSH                = kLynxBit3,
  992.     kLynxATF_FLUSH                = kLynxBit2,
  993.     kLynxFORCE_BIG_ENDIAN        = kLynxBit1,
  994.     kLynxFCT33_WR                = kLynxBit0
  995. };
  996.  
  997. // ATH/ITF Threshold Control
  998.  
  999. enum
  1000. {
  1001.     kLynxATF_TRSHLD                = LynxBitRange (8, 15),
  1002.     kLynxATF_TRSHLDPhase        = LynxBitRangePhase (8, 15),
  1003.     kLynxITF_TRSHLD                = LynxBitRange (0, 7),
  1004.     kLynxITF_TRSHLDPhase        = LynxBitRangePhase (0, 7)
  1005. };
  1006.     
  1007. // DMA stuff
  1008.  
  1009. // Word 0 Receive Packet Compare Value Register @B00 B10 B20 B30 B40
  1010.  
  1011. // Word 0 Receive Packet Compare Enable Register @B04 B14 B24 B34 B44
  1012.  
  1013. enum
  1014. {
  1015.     kLynxCMP0_FIELD1_MASK        = LynxBitRange (16, 31),
  1016.     kLynxCMP0_FIELD1_MASKPhase    = LynxBitRangePhase (16, 31),
  1017.     kLynxCMP0_FIELD2_MASK        = LynxBitRange (8, 15),
  1018.     kLynxCMP0_FIELD2_MASKPhase    = LynxBitRangePhase (8, 15),
  1019.     kLynxCMP0_FIELD3_MASK        = LynxBitRange (4, 7),
  1020.     kLynxCMP0_FIELD3_MASKPhase    = LynxBitRangePhase (4, 7),
  1021.     kLynxCMP0_FIELD4_MASK        = LynxBitRange (0, 3),
  1022.     kLynxCMP0_FIELD4_MASKPhase    = LynxBitRangePhase (0, 3),
  1023.     
  1024.     kLynxIsotCodeNormal            = 0x09,
  1025.     kLynxAsynctCodeNormal        = 0x0A,
  1026.  
  1027.     kLynxMatchIsochChannel        = LynxBitRange (0, 5),
  1028.     kLynxMatchIsochChannelAndTag    = LynxBitRange (0, 7)
  1029. };
  1030.  
  1031. // Word 1 mask (comparator) [b0c, b1c, etc]
  1032.  
  1033. enum
  1034. {
  1035.     kLynkDEST_ID_SEL_BusNode    = kLynxBit11,
  1036.     kLynxRCV_SELF_ID_EN            = kLynxBit10,
  1037.     kLynxEN_DIRECT_ADR            = kLynxBit9,
  1038.     kLynxEN_CH_COMPARE            = kLynxBit8,
  1039.     kLynxWRITE_REQ_ACK_SEL        = kLynxBit7
  1040. };
  1041.  
  1042. // 1394 Bus Number and Node Number
  1043.  
  1044. enum
  1045. {
  1046.     kLynxBUS_ID                    = LynxBitRange (22, 31),
  1047.     kLynxBUS_IDPhase            = LynxBitRangePhase (22, 31),
  1048.     kLynxNODE_ID                = LynxBitRange (16, 21),
  1049.     kLynxNODE_IDPhase            = LynxBitRangePhase (16, 21),
  1050.     kLynxBUS_NODE_ID            = LynxBitRange (16, 31),
  1051.     kLynxBUS_NODE_IDPhase        = LynxBitRangePhase (16, 31)
  1052. };
  1053.  
  1054. // 1394 Link Layer Control
  1055.  
  1056. enum
  1057. {
  1058.     kLynxBUSY_CNTRL                = kLynxBit29,
  1059.     kLynxTX_ISO_EN                = kLynxBit26,
  1060.     kLynxRX_ISO_EN                = kLynxBit25,
  1061.     kLynxTX_ASYNC_EN            = kLynxBit24,
  1062.     kLynxRX_ASYNC_EN            = kLynxBit23,
  1063.     kLynxRSTTX                    = kLynxBit21,
  1064.     kLynxRSTRX                    = kLynxBit20,
  1065.     kLynxCYCMASTER                = kLynxBit11,
  1066.     kLynxCYCSOURCE                = kLynxBit10,
  1067.     kLynxCYCTIMEREN                = kLynxBit9,
  1068.     kLynxRCV_COMP_VALID            = kLynxBit7
  1069. };
  1070.  
  1071. // 1394 Cycle Timer
  1072.  
  1073. enum
  1074. {
  1075.     kLynxCYCLE_NUMBER            = LynxBitRange (12, 31),
  1076.     kLynxCYCLE_NUMBERPhase        = LynxBitRangePhase (12, 31),
  1077.     kLynxCYCLE_OFFSET            = LynxBitRange (0, 11),
  1078.     kLynxCYCLE_OFFSETPhase        = LynxBitRangePhase (0, 11)
  1079. };
  1080.  
  1081. // PHY
  1082.  
  1083. enum
  1084. {
  1085.     kLynxRDPHY                    = kLynxBit31,
  1086.     kLynxWRPHY                    = kLynxBit30,
  1087.     kLynxPHY_REG_ADR            = LynxBitRange (24, 27),
  1088.     kLynxPHY_REG_ADRPhase        = LynxBitRangePhase (24, 27),
  1089.     kLynxPHY_REG_DAT            = LynxBitRange (16, 23),
  1090.     kLynxPHY_REG_DATPhase        = LynxBitRangePhase (16, 23),
  1091.     kLynxPHY_REGRD_ADR            = LynxBitRange (8, 11),
  1092.     kLynxPHY_REGRD_ADRPhase        = LynxBitRangePhase (8, 11),
  1093.     kLynxPHY_REGRD_DAT            = LynxBitRange (0, 7),
  1094.     kLynxPHY_REGRD_DATPhase        = LynxBitRangePhase (0, 7)
  1095. };
  1096.  
  1097. // Diagnostic Test Control
  1098.  
  1099. // 1394 Link Layer Interrupt Status Register and Enable Register
  1100.  
  1101. enum
  1102. {
  1103.     kLynxLINK_INT                = kLynxBit31,
  1104.     kLynxPHY_TIME_OUT            = kLynxBit30,
  1105.     kLynxPHY_REG_RCVD            = kLynxBit29,
  1106.     kLynxPHY_BUSRESET            = kLynxBit28,
  1107.     kLynxTX_RDY                    = kLynxBit26,
  1108.     kLynxRX_DATA_RDY            = kLynxBit25,
  1109.     kLynxIT_STUCK                = kLynxBit20,
  1110.     kLynxAT_STUCK                = kLynxBit19,
  1111.     kLynxSNTRJ                    = kLynxBit17,
  1112.     kLynxHDR_ERR                = kLynxBit16,
  1113.     kLynxTC_ERR                    = kLynxBit15,
  1114.     kLynxCYC_SEC                = kLynxBit11,
  1115.     kLynxCYC_STRT                = kLynxBit10,
  1116.     kLynxCYC_DONE                = kLynxBit9,
  1117.     kLynxCYC_PEND                = kLynxBit8,
  1118.     kLynxCYC_LOST                = kLynxBit7,
  1119.     kLynxCYC_ARB_FAILED            = kLynxBit6,
  1120.     kLynxGRF_OVER_FLOW            = kLynxBit5,
  1121.     kLynxITF_UNDER_FLOW            = kLynxBit4,
  1122.     kLynxATF_UNDER_FLOW            = kLynxBit3,
  1123.     kLynxIARB_FAILED            = kLynxBit0
  1124. };
  1125.  
  1126. // Busy retry register
  1127.  
  1128. enum
  1129. {
  1130.     kLynxBUSY_RETRY_DLY            = LynxBitRange (8, 15),
  1131.     kLynxBUSY_RETRY_DLYPhase    = LynxBitRangePhase (8, 15),
  1132.     kLynxBUSY_RETRY_CNT            = LynxBitRange (0, 7),
  1133.     kLynxBUSY_RETRY_CNTPhase    = LynxBitRangePhase (0, 7)
  1134. };
  1135.  
  1136. // State machine
  1137.  
  1138. // Under/Over counters
  1139.  
  1140. // Lynx's Packet Control Token for GRF:
  1141.  
  1142. enum
  1143. {
  1144.     kLynxGrfPctPKTBD            = kLynxBit31,
  1145.     // missing
  1146.     kLynxGrfPctISO                = kLynxBit17,
  1147.     kLynxGrfPctSELF_ID            = kLynxBit16
  1148.     // missing
  1149. };
  1150.  
  1151. // Lynx's Packet Control Token for ATF:
  1152.  
  1153. enum
  1154. {
  1155.     kLynxAtfPctPKTBNDRY            = kLynxBit31
  1156.     // missing
  1157.     // missing
  1158. };
  1159.  
  1160. // Defs for handling asynch receive overflow.
  1161.  
  1162. enum
  1163. {
  1164.     kLynxNumAsyncRxPCLsToPrime    = 20
  1165. };
  1166.  
  1167. // Defs for pending FWIM commands.
  1168.  
  1169. enum
  1170. {
  1171.     kLynxPendingFWIMCommandBusy    = 1
  1172. };
  1173.  
  1174.  
  1175. struct LynxDMAChannelInfoStruct
  1176. {
  1177.     FWDeferredTaskID            lynxDT;                    // A deferred task for this guy
  1178.     UInt32                        channelType;            // What kind of DMA we're doing on this channel
  1179.     DCLProgramID                dclProgram;                // Used to lookup what Channel is used for which DCL Program
  1180.     Boolean                        lynxDTScheduled;        // True if the DT is scheduled
  1181.     Boolean                        inUse;                    // True if this channel is being used
  1182.     UInt8                        pad[2];
  1183. };
  1184. typedef struct LynxDMAChannelInfoStruct
  1185.                                 LynxDMAChannelInfo,
  1186.                                 *LynxDMAChannelInfoPtr;
  1187.  
  1188. // Defs for channelType                                
  1189. enum
  1190. {
  1191.     kChannelUnused,                                        // Should be obvious
  1192.     kAsyncXmit,                                            // Asynchronous Transmit
  1193.     kAsyncRcv,                                            // Asynchronous Receive
  1194.     kAsyncWriteAccel,                                    // block write acceleration for nnnn.0000.mmmm.mmmm
  1195.     kAsyncReadAccelRx,                                    // block read acceleration for nnnn.0000.mmmm.mmmm Rx Channel for incoming requests
  1196.     kAsyncReadAccelTx,                                    // block read acceleration for nnnn.0000.mmmm.mmmm Tx Channel for response w/Data
  1197.     kIsochXmit,                                            // Asynchronous Transmit
  1198.     kIsochRcv                                            // Asynchronous Receive
  1199. };
  1200.  
  1201. struct LynxIsochPortDataStruct
  1202. {
  1203.     DCLProgramID                dclProgramID,            // ID of DCL program we're using.
  1204.                                 originalDCLProgramID,    // Original DCL program ID.
  1205.                                 translatedDCLProgramID;    // Translated DCL program ID.
  1206.     UInt32                        channelNum;                // Isoch channel number used for this port.
  1207.     UInt32                        dmaChannel;                // actual DMA channel used for this guy.
  1208.     UInt32                        speed;                    // Speed of this port.
  1209.     Boolean                        talking;                // True if port is for talking.
  1210. };
  1211. typedef struct LynxIsochPortDataStruct
  1212.                                 LynxIsochPortData,
  1213.                                 *LynxIsochPortDataPtr;
  1214.                                 
  1215. struct LynxAsyncRxPCLDataStruct
  1216. {
  1217.     LynxPCLPtr                    pNextPCL;                // Logical pointer to next PCL.
  1218.     struct LynxFWIMDataStruct    *pLynxFWIMData;            // Pointer to Lynx FWIM data.
  1219.     Ptr                            pPCLPhysical;            // Physical pointer to PCL.
  1220.     Ptr                            packetBuffer;            // Logical packet buffer of PCL.
  1221.     FWIMProcessAsynchParams        fwimProcessAsynchParams;    // Params for processing received requests.
  1222. };
  1223. typedef struct LynxAsyncRxPCLDataStruct
  1224.                                 LynxAsyncRxPCLData,
  1225.                                 *LynxAsyncRxPCLDataPtr;
  1226.  
  1227. struct LynxAsyncTxPCLDataStruct
  1228. {
  1229.     LynxPCLPtr                    pNextPCL;                // Logical pointer to next PCL.
  1230.     struct LynxFWIMDataStruct    *pLynxFWIMData;            // Pointer to Lynx FWIM data.
  1231.     Ptr                            pPCLPhysical;            // Physical pointer to PCL.
  1232. };
  1233. typedef struct LynxAsyncTxPCLDataStruct
  1234.                                 LynxAsyncTxPCLData,
  1235.                                 *LynxAsyncTxPCLDataPtr;
  1236.  
  1237. typedef struct LynxDCLProgramInterruptQueueElementStruct
  1238.                                 LynxDCLProgramInterruptQueueElement,
  1239.                                 *LynxDCLProgramInterruptQueueElementPtr;
  1240.  
  1241. struct LynxDCLProgramInterruptQueueElementStruct
  1242. {
  1243.     LynxDCLProgramInterruptQueueElementPtr
  1244.                                 pPrevDCLInterrupt;        // Link to previous interrupt queue element.
  1245.     DCLCommandPtr                pDCLCommand;            // Pointer to DCL command that caused interrupt.
  1246. };
  1247.  
  1248. enum
  1249. {
  1250.     kPendingResetRequestsAllowed = 5                    // number of pending reset requests allowed
  1251. };
  1252.  
  1253. struct PendingResetReqStruct                            // holds a pending bus reset request
  1254. {
  1255.     Boolean                        inUse;
  1256.     FWIMCommandParamsPtr        pPendingResetRequest;
  1257. };
  1258. typedef struct PendingResetReqStruct
  1259.                                 PendingResetReq,
  1260.                                 *PendingResetReqPtr;
  1261.  
  1262. // Private data structure for LynxFWIM - one per Lynx
  1263.  
  1264. struct LynxFWIMDataStruct
  1265. {
  1266.     // Some fields within this struct will be physically addressed by commands in a PCL program.
  1267.     // We will only map the first page of this struct physically, so these fields must be within
  1268.     // the first page.  So don't rearrange this part of the struct.
  1269.     
  1270.     LynxDCLProgramInterruptQueueElementPtr
  1271.                                 pDCLInterruptTail[kNumDMAChannels];    // Tails of DCL interrupt queues.
  1272.     LynxDCLProgramInterruptQueueElementPtr
  1273.                                 pDCLLastInterrupt[kNumDMAChannels];    // The last DCL command serviced                            
  1274.     volatile UInt32                asyncTxDoneFlag;                // Flag indicating that asynchronous transmit has finished.
  1275.     UInt32                        asyncRxOverflowSetLinkControl;    // Value to set link control register with on receive overflow.
  1276.     UInt32                        asyncRxOverflowSetPCLComparator;// Value to set PCL comparator register with on receive overflow.
  1277.     UInt32                        asyncRxOverflowFlag;            // Flag indicating an overflow in async receive.
  1278.     UInt32                        accelReadTXBusy;                // Flag indicating we are busy transmitting a read response
  1279.     UInt32                        accelReadTxThrottle;            // Flag telling DMA to stop
  1280.  
  1281.     // Nothing below this line will be accessed via physical addresses
  1282.     
  1283.     PhysicalAddress                fwimDataPhys;                    // Physical address of this struct
  1284.     IOPreparationTable            fwimDataIOPrep;                    // ioPrep data for this struct
  1285.     IOPreparationID                atfIOPreparationID;                // ioPrepID for current asynch transmit request
  1286.     FWIMID                        fwimID;                            // ID for this FWIM
  1287.     RegEntryID                    FWIMRegEntryID;                    // Name registry ID for TI card.
  1288.     UInt32                        generation;                        // Current bus generation number.
  1289.     Boolean                        generationValid;                // Generation number is valid.
  1290.     Boolean                        root;                            // True if we're root.
  1291.     Boolean                        lynxPad0[2];                    // Pad to long word
  1292.  
  1293.     TimerID                        holdoffResetRequestsTimerID;    // TimerID for holding off bus reset requests
  1294.     TimerID                        requestTimeoutTimerID;            // TimerID to indicate timeout of a read/write request
  1295.     FWDeferredTaskID            busResetDeferredTaskID;            // Deferred task ID for handling bus resets.
  1296.  
  1297.     LynxDMAChannelInfo            DMAInfo[kNumDMAChannels];        // Deferred tasks and other info per channel
  1298.                                                                 // including allocation and in use flags
  1299.     UInt32                        asyncRxDMA;                        // Channel allocated for Async Receive used for quick access
  1300.     UInt32                        asyncTxDMA;                        // Channel allocated for Async Transmit used for quick access
  1301.     UInt32                        asyncAccelWriteDMA;                // Channel allocated for Async Write Acceleration used for quick access
  1302.     UInt32                        asyncAccelReadRxDMA;            // Channel allocated for Async Read Acceleration used for quick access
  1303.     UInt32                        asyncAccelReadTxDMA;            // Channel allocated for Async Read Acceleration used for quick access
  1304.  
  1305.     FWDeferredTaskID            miscInterruptDeferredTaskID;    // Deferred task ID for handling misc interrupts.
  1306.  
  1307.     Boolean                        holdoffResetRequestsTimerSet;    // Flag indicating the ResetRequests timer is running
  1308.     Boolean                        requestTimeoutTimerSet;            // Flag indicating the Timeout timer is running
  1309.     Boolean                        busResetDTScheduled;            // True if we've scheduled a DT to handle bus resets.
  1310.     Boolean                        miscInterruptDTScheduled;        // True if we've sceduled a DT to handle misc interrupts.
  1311.  
  1312.     UInt32                        miscInterrupt;                    // Miscellaneous interrupt to deal with
  1313.     FWIMCommandParamsPtr        pPendingFWIMCommand;            // Pending FWIM command.
  1314.     OSStatus                    pendingFWIMCommandStatus;        // Internal status of pending FWIM command.
  1315.     FWIMCommandParamsPtr        pPendingFWIMResponseCommand;    // Pending FWIM response command.
  1316.     UInt32                        transactionLabel;                // Label used for current transaction
  1317.     UInt32                        tCode;                            // TCode for current transaction.
  1318.     DCLCommandPtr                pCurrentDCLCommand;                // Pointer to current DCL command.
  1319.     InterruptSetMember            interruptSetMember;
  1320.     void                        *oldInterruptRefCon;
  1321.     InterruptHandler            oldInterruptHandler;
  1322.     InterruptEnabler            interruptEnabler;
  1323.     InterruptEnabler            interruptOldEnabler;
  1324.     InterruptDisabler            interruptDisabler;
  1325.     InterruptDisabler            interruptOldDisabler;
  1326.     LynxRegistersPtr            pLynxRegisters;                    // Register file
  1327.     
  1328.     Ptr                            asyncBuf[kAsyncBufs];            // Non-isoch
  1329.     Ptr                            asyncBufPhys[kAsyncBufs];        // Physical addrs
  1330.  
  1331.     LynxPCL                        *asyncXmitPCL;                    // two for transmit
  1332.     Ptr                            asyncXmitPCLPhys;                // Physical addrs
  1333.     LynxPCLPtr                    pNextAsyncTxPCL;                // Pointer to next active async transmit PCL to process.
  1334.     LynxPCLPtr                    pLastAsyncTxPCL;                // Pointer to last active async transmit PCL.
  1335.     LynxPCLPtr                    asyncTxDonePCLSegment;            // PCL segment to deal with finished async transmit.
  1336.     LynxAsyncTxPCLDataPtr        lynxAsyncTxPCLDataList;            // List of data records for async transmit PCLs.
  1337.  
  1338.     LynxPCL                        *asyncPCL;                        // async PCL loop
  1339.     LynxPCLPtr                    pNextAsyncPCL;                    // Next async receive PCL to process.
  1340.     LynxPCLPtr                    pLastAsyncPCL;                    // Last available async receive PCL.
  1341.     LynxPCLPtr                    pStartAsyncRxPCL;                // Async receive PCL to start receive program.
  1342.     UInt32                        numAsyncRxPCLsPrimed;            // Number of receive PCLs primed.
  1343.     LynxPCLPtr                    asyncRxOverflowPCLSegment;        // PCL segment to deal with async receive overflow.
  1344.     Ptr                            asyncPCLPhys;                    // Physical addrs
  1345.     LynxAsyncRxPCLDataPtr        lynxAsyncRxPCLDataList;            // List of data records for async receive PCLs.
  1346.     Ptr                            asyncXmitBuf;                    // For Async xmit
  1347.     Ptr                            asyncXmitBufPhys;                // Physical
  1348.     IOPreparationTable            ioPrep;                            // For VM
  1349.     PhysicalAddress                physAddrs[kAsyncBufs+20];        // Page table - fix this •••
  1350.     LynxIsochPortDataPtr        lynxIsochPortDataList[kNumDMAChannels];    // List of isoch port data records.
  1351.     SInt32                        isochTransmitMode;                // > 0 if we're in isochronous transmit mode. 1 per XMIT channel
  1352.     UInt32                        pageSize,                        // Physical page size and shift for VM.
  1353.                                 pageShift;
  1354.     UInt32                        bitBucket;                        // Bit bucket to dump stuff into.
  1355.     Boolean                        eepromValid;                    // True if we have read and CRCed the EEPROM
  1356.     Boolean                        lynxPad3[3];                    // Pad to long word
  1357.     UInt32                        eepromData[kLynxMinEEPROMQuads];    // Raw EEPROM quads
  1358.     LynxEEPROMInfo                eepromInfo;                        // Info derived from EEPROM
  1359.     TimerID                        delayedResetTimerID;            // (temporary hack)
  1360.     Boolean                        delayedResetTimerSet;            // Flag indicating the above timer is running
  1361.  
  1362.     UInt8                        lastPhyReg0;                    // Last known value of PHY register zero
  1363.     Boolean                        extendedPhyRegs;                // True if we have a 1394a PHY with the extended register set                    
  1364.     Boolean                        receiveLocalSelfID;                // True if PHY sends us our own self ID            
  1365.     TimerID                        phyRegTimerID;                    // If the above is true we need to wait a bit to see if we get a 
  1366.                                                                 // PHYRegReceived interrupt later. If not the data from the previous
  1367.                                                                 // one was valid so we can use it.
  1368.  
  1369.     UInt32                        lastARDMA;                        // ARDMA PCL last time we sent a bus reset
  1370.     UInt32                        lastFIFOa;                        // FIFO pointers last time we sent a bus reset
  1371.     UInt32                        lastFIFOb;                        // FIFO pointers last time we sent a bus reset
  1372.     PendingResetReqPtr            pResetRequestList;                // list to hold bus reset requests
  1373.     
  1374.     UInt32                        localSelfIDQuads[8];            // Support lots of ports. Overkill probably
  1375.     LynxPCLPtr                    selfIDPackets;                    // Leave this here til we inform the FSL and
  1376.                                                                 // then recycle the PCL
  1377.     Ptr                            selfIDPacketBuffer;                // The actual self-id packets
  1378.     UInt32                        selfIDPacketSize;                // Size of the packet containing the self IDs.
  1379.     UInt32                        numPHYPorts;                    // Number of ports supported by the PHY
  1380.     SInt32                        fwimBusy;                        // Non zero if we are busy and don't want to re-enter our SIHs
  1381.     
  1382.     LynxPCLPtr                    asyncAccelWritePCLPhys;            // Physical addrs
  1383.     LynxPCLPtr                    asyncAccelWritePCLLog;            // Pointer to one of the two PCLs in the loop.
  1384.  
  1385.     LynxPCLPtr                    asyncAccelReadPCLRxPhys;        // Physical addrs
  1386.     LynxPCLPtr                    asyncAccelReadPCLRxLog;            // Pointer to one of the PCLs in the loop.
  1387.  
  1388.     LynxPCLPtr                    asyncAccelReadPCLTxPhys;        // Physical addrs
  1389.     LynxPCLPtr                    asyncAccelReadPCLTxLog;            // Pointer to one of the PCLs in the loop.
  1390.     
  1391.     UInt8                        * asyncAccelReadHeaderLog;        // Logical Pointer to the buffer for our outgoing packet header
  1392.     UInt8                        * asyncAccelReadHeaderPhys;        // Physical Pointer to the buffer for our outgoing packet header
  1393.     
  1394.     LynxPCLPtr                    phyRegAccessLog;                // Logical addr of PCL used to 
  1395.     LynxPCLPtr                    phyRegAccessPhys;                // Pointer to one of the PCLs in the loop.
  1396.     
  1397.     SInt32                        intsDisabledCount;                // Number of times interrupts have been disabled
  1398.     UInt32                        interruptMask;                    // What interrupts should be enabled.
  1399.     
  1400.     SInt32                        phyRegAccessStack;                // Used to prevent re-entrant PHY access from using the same PCL
  1401.     SInt32                        phyNotPowered;                    // non-zero if PHY isn't powered.
  1402.     TimerID                        phyPowerTimerID;                // TimerID for waiting for PHY Power
  1403.     
  1404.     UInt32                        interruptValues[4];                // For debugging - last 4 interrupts
  1405.     UInt32                        *csrROMUpdateClearWhenDone;        // For OHCI example.
  1406.     
  1407.     Ptr                            baseFWIMDataPtr;                // Actual Ptr returned by PoolAllocateResident
  1408.     Ptr                            basePCLData;                    // Ditto
  1409.     Ptr                            baseRxData;                        // Ditto
  1410.     Ptr                            baseTxData;                        // Ditto
  1411.     
  1412.     Boolean                        phyNodeThoughtValid;            // True if we we think the Node ID is valid but we saw a reset interrupt
  1413.                                                                 // at the same time we processed the phyRegReceived interrupt. 
  1414.     Boolean                        lynxPad4[3];                    // Pad to long word
  1415.  
  1416. };
  1417. typedef struct LynxFWIMDataStruct        LynxFWIMData, *LynxFWIMDataPtr;
  1418.  
  1419. enum
  1420. {
  1421.     kPCLPoolSize                = 100,
  1422.     kPCLAlignmentMask            = 0xFFFFFF80
  1423. };
  1424.  
  1425. typedef struct LynxPCLPoolDataStruct
  1426.                                 LynxPCLPoolData,
  1427.                                 *LynxPCLPoolDataPtr;
  1428. struct LynxPCLPoolDataStruct
  1429. {
  1430.     LynxPCLPoolDataPtr            pNextLynxPCLPoolData;    // Link to next PCL pool data record.
  1431.     UInt32                        nextFreePCL;            // Next free PCL in pool.
  1432.     LynxPCLPtr                    alignedPCLPoolBase;        // 128-byte-aligned PCL pool base address.
  1433.     UInt32                        alignedPCLPoolBasePhys;    // Physical addr of same
  1434.     LogicalAddress                poolAllocatedAddress;    // Actual allocated address
  1435.     IOPreparationTable            ioPrep;                    // For VM
  1436.     PhysicalAddress                physAddrs[20];            // warning, arbitrary constant
  1437.     UInt32                        isochPacketHeader;        // Storage for isoch packet header.
  1438.     PhysicalAddress                isochPacketHeaderPhys;    // Physical addr of previous UInt32
  1439.     LynxPCL                        pclPoolDummy[kPCLPoolSize];    // Space for PCL pool array.
  1440. };
  1441.  
  1442. enum
  1443. {
  1444.     kLynxPCLUnknownType            = 0,
  1445.     kLynxPCLStartType            = 1,
  1446.     kLynxPCLTransferType        = 2,
  1447.     kLynxPCLAuxType                = 3
  1448. };
  1449.  
  1450. enum
  1451. {
  1452.     kLynxPhysicalBuffer            = 0,
  1453.     kLynxLogicalBuffer            = 1
  1454. };
  1455.  
  1456. struct LynxDCLCompilerEngineDataStruct
  1457. {
  1458.     LynxFWIMDataPtr                pLynxFWIMData;            // Our FWIM data.
  1459.     LynxPCLPtr                    pStartPCL;                // Pointer to first PCL in compiled program.
  1460.     LynxPCLPoolDataPtr            pLynxPCLPoolDataList;    // List of PCL pools allocated for this copmiled program.
  1461.     UInt32                        *isochPacketHeaderPtr;    // Storage for isoch packet header.
  1462.     PhysicalAddress                isochPacketHeaderPhys;    // Phys addr stolen from PCL pool
  1463.     UInt32                        engineGeneration;        // For faster lookups
  1464.     IOPreparationTable            ioPrep;                    // For all buffers/etc
  1465.     PhysicalAddress                *physAddrs;                // Page table (of sorts)
  1466. };
  1467. typedef struct LynxDCLCompilerEngineDataStruct
  1468.                                 LynxDCLCompilerEngineData,
  1469.                                 *LynxDCLCompilerEngineDataPtr;
  1470.  
  1471. struct LynxPCLBuildStateStruct
  1472. {
  1473.     LynxFWIMDataPtr                pLynxFWIMData;            // Our FWIM data.
  1474.     LynxDCLCompilerEngineDataPtr
  1475.                                 pLynxDCLCompilerEngineData;    // Compiler engine data.
  1476.     UInt32                        pclChannelNum;            // PCL channel number we're building for.
  1477.     LynxPCLPoolDataPtr            pLynxPCLPoolDataList;    // List of PCL pools allocated for this build.
  1478.     LynxPCLPtr                    pFirstPCL;                // First physical PCL for this logical PCL.
  1479.     LynxPCLPtr                    pCurrentPCL;            // Current working PCL.
  1480.     UInt32                        currentBuffer;            // Current working buffer in PCL.
  1481.     UInt32                        lastBuffer;                // Last unallocated buffer.
  1482.     UInt32                        bufferAllocationSize;    // Amount allocated from current allocation buffer.
  1483.     UInt32                        pclType;                // Start, transfer, or aux.
  1484.     UInt32                        refCon;                    // Ref con.
  1485.     UInt32                        commandWord;            // Command word if this is a transfer PCL.
  1486.     Boolean                        interrupt;                // True if we want to generate an interrupt.
  1487.     UInt32                        isochChannelNum;        // Isochronous channel number.
  1488. };
  1489. typedef struct LynxPCLBuildStateStruct    LynxPCLBuildState, *LynxPCLBuildStatePtr;
  1490.  
  1491. struct LynxPCLLabelStruct
  1492. {
  1493.     LynxPCLPtr                    pLabelLynxPCL;            // PCL that label refers to.
  1494.     LynxPCLPtr                    *pLabelDependencyList;    // List of label dependencies.
  1495. };
  1496. typedef struct LynxPCLLabelStruct    LynxPCLLabel, *LynxPCLLabelPtr;
  1497.  
  1498. #if PRAGMA_ALIGN_SUPPORTED
  1499. #pragma options align=reset
  1500. #endif
  1501.  
  1502. #if PRAGMA_IMPORT_SUPPORTED
  1503. #pragma import off
  1504. #endif
  1505.  
  1506. #ifdef __cplusplus
  1507. }
  1508. #endif
  1509.  
  1510. #endif /* __LYNXFWIM__ */
  1511.